|
RtCreateSharedMemory creates a named region of physical memory that can be mapped by any process.
Syntax
HANDLE RtCreateSharedMemory( DWORD flProtect, DWORD MaximumSizeHigh, DWORD MaximumSizeLow, LPCTSTR lpName, VOID ** location );
Parameters
flProtect (ignored by RTSS)
The protection desired for the shared memory view. This parameter can be one of the following values:
Gives read-only access to the committed region of pages. An attempt to write to or execute the committed region results in an access violation.
Gives read-write access to the committed region of pages.
MaximumSizeHigh
The high-order 32 bits of the size of the shared memory object. This value can only be zero (0).
MaximumSizeLow
The low-order 32 bits of the size of the shared memory object.
lpName
A pointer to a null-terminated string specifying the name of the shared memory object. The name can contain any character except the backslash (\).
If this parameter matches the name of an existing named shared memory object, the function requests access to the shared memory object with the protection specified by flProtect.
If lpName matches the name of an existing event, mutex, or semaphore object, the function fails and GetLastError returns ERROR_INVALID_HANDLE. This occurs because event, mutex, semaphore, and shared memory objects share the same namespace.
If lpName is NULL, the mapping object is created without a name.
location
A pointer to a location where the virtual address of the shared memory will be stored.
Return Values
A handle to the shared memory object if the function succeeds, NULL if the function fails
To get extended error information, call GetLastError.
If the shared memory object existed before the function call, GetLastError returns ERROR_ALREADY_EXISTS, and the return value is a valid handle to the existing shared memory object. If the mapping object did not exist, GetLastError returns zero and the location is set.
IMPORTANT! If you call RtCreateSharedMemory from an RTSS process for an existing named object but you specify a size different than the current size of the object, the size of the shared memory remains the same as when it was first created and that value is returned.
NOTE: If you call RtCreateSharedMemory from a Windows process, and you specify a size different than the current size of the object, the size of the object that is mapped into the process space is equal to the requested size. If the requested size is greater than the original size of the object, the object size is increased.
Remarks
The handle that RtCreateSharedMemory returns has full access to the new shared memory object. Shared memory objects can be shared by name. If you use RtCreateSharedMemory and the named object already exists, the behavior is similar to the behavior of RtOpenSharedMemory. For information on opening a shared memory object by name, see RtOpenSharedMemory.
To close a shared memory object, an application must close its handle by calling RtCloseHandle.
When all handles to the shared memory object representing the physical memory are closed, the object is destroyed and physical memory is returned to the system.
Requirements
Header | Rtapi.h |
Library | rtapi_w32.lib (Windows), Rtx_Rtss.lib (RTSS) |
See Also: